package com.example.boot0502.controller;

import com.example.boot0502.mapper.PetMapper;
import com.example.boot0502.entity.Pet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PetController {
    @Autowired
    PetMapper mapper;
    @RequestMapping("/petadd")
    public int petadd(@RequestBody  Pet pet){
        Pet p = mapper.select(pet.getType());
        if(p==null){
            mapper.insert(pet);
            return 1;
        }
        return 2;
    }
    @RequestMapping("/check")
    public int check(String type){
        Pet p = mapper.select(type);
        return p==null?1:2;
    }
}
